package cn.tedu.ivos.repair.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.repair.pojo.dto.RepairParam;
import cn.tedu.ivos.repair.pojo.dto.RepairQuery;
import cn.tedu.ivos.repair.pojo.vo.RepairVO;
import cn.tedu.ivos.repair.service.RepairService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@Api(tags = "报修模块")
@Validated
@RestController
@RequestMapping("/v1/repair/")
public class RepairController {
    @Autowired
    RepairService repairService;

    @ApiOperation("查询车辆报修信息")
    @GetMapping("select")
    public JsonResult selectAll(@Validated RepairQuery repairQuery){
        log.debug("查询车辆报修信息 repairQuery={}", repairQuery);
        List<RepairVO> list = repairService.selectAll(repairQuery);
        return JsonResult.ok(list);
    }

    @ApiOperation("保存或修改车辆信息")
    @PostMapping("save")
    public JsonResult save(@Validated RepairParam repairParam){
        log.debug("保存或修改车辆信息 repairParam={}", repairParam);
        repairService.save(repairParam);
        return JsonResult.ok();
    }

}
